package com.hellpro.lolbox.mine.view;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hellpro.lolbox.R;
import com.hellpro.lolbox.base.LolBaseActivity;
import com.hellpro.lolbox.mine.presenter.RegisterPresenter;
import com.hellpro.lolbox.utils.UIManger;

import butterknife.BindView;
import butterknife.OnClick;
import cn.bmob.sms.BmobSMS;


public class RegisterActivity extends LolBaseActivity implements IRegisterActivity {

    @BindView(R.id.main_register_iv_return)
    ImageView mainRegisterIvReturn;
    @BindView(R.id.mine_register_ll_title)
    LinearLayout mineRegisterLlTitle;
    @BindView(R.id.mine_register_et_phoneNo)
    EditText mineRegisterEtPhoneNo;
    @BindView(R.id.mine_register_ll_content)
    LinearLayout mineRegisterLlContent;
    @BindView(R.id.mine_register_btn_smsCode)
    Button mineRegisterBtnSmsCode;
    @BindView(R.id.mine_register_tv_content)
    TextView mineRegisterTvContent;
    @BindView(R.id.activity_register)
    RelativeLayout activityRegister;
    private RegisterPresenter presenter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_register;
    }

    @Override
    public void initView() {
        //初始化数据库
        BmobSMS.initialize(this, "b9e80a06ccaa5632b74a3e3f12aedc9b");
        presenter = new RegisterPresenter(this);
    }

    @OnClick({R.id.main_register_iv_return, R.id.mine_register_et_phoneNo, R.id.mine_register_btn_smsCode, R.id.mine_register_tv_content})
    public void onClick(View view) {
        switch (view.getId()) {
            //处理退出键的方法
            case R.id.main_register_iv_return:
                finish();
                break;
            //处理手机号的输入框
            case R.id.mine_register_et_phoneNo:

                break;
            //获取验证码
            case R.id.mine_register_btn_smsCode:
                presenter.setRegisterSmsCode();
                final String phoneNo =mineRegisterEtPhoneNo.getText().toString().trim();
                UIManger.startToSmsActivity(RegisterActivity.this, SmsVerificationActivity.class, phoneNo);
                finish();
                break;
            //查看用户协议
            case R.id.mine_register_tv_content:

                break;
        }
    }

    @Override
    public EditText getRegisterPhone() {
        return mineRegisterEtPhoneNo;
    }

    @Override
    public Button getRegisterSmsCode() {
        return mineRegisterBtnSmsCode;
    }

    @Override
    public Context getRegisterContext() {
        return RegisterActivity.this;
    }

    @Override
    public TextView getRegisterTvContent() {
        return mineRegisterTvContent;
    }
}
